﻿using System;
using System.Diagnostics;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YJKRevitBase.WinForm;
using YJKInspectModel.ModelValidation.AdjoinFireZone;

namespace YJKInspectModel.ModelValidation.Commands
{
	[Transaction(TransactionMode.Manual)]
	public class CmdAdjoinFireZoneVer : IExternalCommand
	{
		public Result Execute(ExternalCommandData cmdData, ref string messages, ElementSet elements)
		{
            WindowHandle windowHandle = null;
			if (windowHandle == null)
			{
                windowHandle = new WindowHandle(Process.GetCurrentProcess().MainWindowHandle);
			}
			bool bIsHorViewPlan = false;
			AdjoinFireZoneCheck adjoinFireZoneCheck = new AdjoinFireZoneCheck(cmdData, bIsHorViewPlan, windowHandle);
			if (!adjoinFireZoneCheck.GetTolViewPlan())
			{
				return Autodesk.Revit.UI.Result.Cancelled;
			}
			if (!adjoinFireZoneCheck.SelectSetSprinkler())
			{
				return Autodesk.Revit.UI.Result.Cancelled;
			}
			AdjoinFireZoneHorApplication.thisApp.ShowForm(cmdData, windowHandle, adjoinFireZoneCheck);
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
